﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using Common;
namespace Model
{
   [Serializable]
   public class exFullInfoForBuildChild:ICloneable
    {
       /// <summary>
       /// 布局Item包含的控件名（BuildName）
       /// </summary>
        public string InControl { get; set; }

       /// <summary>
       /// 父布局的名字（buildname）
       /// </summary>
        public string ParentLayoutName { get; set; }

        public bool IsBase { get; set; }

        public bool IsLayout { get; set; }

        public enumLayoutTypeSimple LayoutType { get; set; }

        public enumBaseControlType BaseType { get; set; }

       /// <summary>
       /// 控件名如（TextBox）
       /// </summary>
        public string ControlName { get;  set; }

        /// <summary>
        /// 控件的全名包括程序集名(DevExpress.XtraLayout.LayoutControlGroup, DevExpress.XtraLayout.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a)
        /// </summary>
        public string ControlFullName { get; set; }

       /// <summary>
       /// 布局的前缀名字
       /// </summary>
        public string LayoutText { get; set; }

        /// <summary>
        /// （Dev，Win or Web）
        /// </summary>
        public string ControlClass { get;  set; }

       /// <summary>
       /// 唯一值
       /// </summary>
        public string BuildName { get;  set; }

        //public string MyProperty { get;  set; }

       /// <summary>
       /// 属性列表
       /// </summary>
        public List<eProperty> PropertyList
        {
            get
            {
                if (_PropertyList == null)
                    _PropertyList = new List<eProperty>();
                return _PropertyList;
            }
            set { _PropertyList = value; }
        }
        private List<eProperty> _PropertyList;
        
       /// <summary>
       /// 包含的控件（buildname）列表，用于基底布局
       /// </summary>
        public  List<string> ControlsList
        {
           get
            {
                if (_ControlsList == null)
                    _ControlsList = new List<string>();
                return _ControlsList;
            }
            set
            {
                _ControlsList = value;
            }
        }
        private List<string> _ControlsList;
        
        /// <summary>
        /// 子节点(buildname)列表用于布局
        /// </summary>
        public  List<string> ChildNodes
        {
            get
            {
                if (_ChildNodes == null)
                    _ChildNodes = new List<string>();
                return _ChildNodes;
            }
            set
            {
                _ChildNodes = value;
            }
        }
        private List<string> _ChildNodes;

        public object Clone()
         {
             using (MemoryStream ms = new MemoryStream(1000))
             {
                 object CloneObject;
                 BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
                 bf.Serialize(ms, this);
                 ms.Seek(0, SeekOrigin.Begin);
                 // 反序列化至另一个对象（即创建了一个原对象的深表副本）
                 CloneObject = bf.Deserialize(ms);
                 // 关闭流 
                 ms.Close();
                return CloneObject;
             }
         }
       /// <summary>
       /// 该实例的深拷贝
       /// </summary>
       /// <returns></returns>
        public exFullInfoForBuildChild DeepCopy()
        {
            return (exFullInfoForBuildChild)Clone();
        }


        public string FieldName { get; set; }
        public string FieldType { get; set; }
    }
}
